-- enemy_ability_cure
-- create by wangy
-- 回复敌方战力的N%血量

return {
    apply = function(source, target, skillId, round, para, value)
        -- 回复敌方战力的N%血量
        local hp = tonumber(value);

        -- 回复值不够
        if hp <= 0 then
            return;
        end

        source:addAttrib("hp", hp);
        trace("enemy_ability_cure", "%s 回复 %d 点生命，当前生命值 %d", source:getName(), hp, source:queryAttrib("hp"));
        return { ["damage"] = 0, ["cure"] = hp, };
    end,

    parse = function(desc)
        local arr = string.explode(desc, ",");
        return { tonumber(arr[1]), arr[2], tonumber(arr[3] or 0)};
    end,

    getDetail = function(para)
        local desc;
        local value = para[1] / 10;
        local valueLimit = para[3] / 10;

        -- 分为按总战力计算和按当前战力计算
        if para[2] == "fight_ability" then
            desc = getLocStr("shipskill_enemy_ability_cure_1");
        elseif para[2] == "hp" then
            desc = getLocStr("shipskill_enemy_ability_cure_2");
        end
        desc = string.format(desc, value, valueLimit);

        return desc;
    end,

    parseDesc = function(desc, para)
        -- 治疗量，每次替换一个
        return string.gsub(desc, "{cure}", math.modf(para[1] / 10), 1);
    end,
};

